-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: Fix block randomization on circuit breaking tests #127909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESQL: Fix block randomization on circuit breaking tests #127909
Conversation
# Conflicts: # muted-tests.yml
# Conflicts: # muted-tests.yml
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
| private boolean shouldRandomizeBlocks() { | ||
| return Arrays.stream(Thread.currentThread().getStackTrace()) | ||
| .noneMatch( | ||
| e -> e.getClassName().equals(OperatorTestCase.class.getName()) && e.getMethodName().equals("testSimpleCircuitBreaking") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we had C#'s nameof() to make this more robust. But I think adding that link in the javadoc is the only simple option we have (?)
nik9000
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd really prefer to do this with a function parameter. It's an extra parameter in a zillion places, but it feels more honest.
| protected record SimpleOptions(boolean requiresDeterministicFactory) { | ||
| public static final SimpleOptions DEFAULT = new SimpleOptions(false); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created this structure instead of just a boolean as it's:
- Easier to understand from callers
- Extendable (Not a big concern now, but the first point makes more sense to me)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| /** | ||
| * Calls {@link #simple(SimpleOptions)} with the default options. | ||
| */ | ||
| protected final Operator.OperatorFactory simple() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added those methods to keep changes at a minimum
| public final void testSimpleCircuitBreaking() { | ||
| ByteSizeValue memoryLimitForSimple = enoughMemoryForSimple(); | ||
| Operator.OperatorFactory simple = simple(); | ||
| Operator.OperatorFactory simple = simple(new SimpleOptions(true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is the method actually using the new param
| protected record SimpleOptions(boolean requiresDeterministicFactory) { | ||
| public static final SimpleOptions DEFAULT = new SimpleOptions(false); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Fixes #127833
A Block type randomization was added here (32588b5) to test different code paths based on the specific agg groupIds block type.
Now, a circuit breaking test fails sometimes, as it expects memory usage to be exact and deterministic, and the randomization may choose a more or less optimum path, changing the memory usage.